package br.ufmg.dcc.simulesspl.view;

import java.util.List;
import java.util.Scanner;

import br.ufmg.dcc.simulesspl.model.ProjectCard;
import br.ufmg.dcc.simulesspl.model.ProjectSelection;

public class ProjectSelectionView extends AbstractView {

	private ProjectSelection projectSelection = new ProjectSelection();

	public void chooseProject() throws Exception {
		Scanner scanner = new Scanner(System.in);
		int choice = Integer.valueOf(scanner.nextLine());
		getGameBoard().setProject(projectSelection.select(choice));

	}

	public void showInvalidProjectMessage() {
		System.out.println(i18n().str("(Invaid project)"));
		System.out.println();
	}

	public void showSelected() {
		System.out.println(i18n().str("Your project is: ") + new ProjectCardView(getGameBoard().getProject()).toString());
	}

	public void showProjects() {
		List<ProjectCard> projects = projectSelection.getProjectOptions();

		System.out.println(i18n().str("Select a project below"));
		for (int i = 0; i < projects.size(); i++) {
			//System.out.println(String.format("Project %d: %s", i + 1, projects.get(i).toString()));
			System.out.println(String.format("%s %d: %s", i18n().str("Project"), i + 1, projects.get(i).getName()) + "\t" + i18n().str("COST") + " = " + projects.get(i).getSize());
		}
		System.out.println();
		System.out.println(i18n().str("Your choice: "));
	}
}
